package com.xf.common.core.authe.feign;

import com.xf.common.core.domain.DmpResult;
import com.xf.common.core.entity.dmp.DmpAuthResourceRole;
import com.xf.common.core.entity.dmp.DmpAuthUser;
import com.xf.common.core.entity.dmp.RegisterUserDto;
import com.xf.common.core.entity.system.SystemUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author JoeyLiu
 * @create 2022-03-31 14:20
 */
@FeignClient(name = "userConsumer", url = "${dmp.saas.user.url.prefix}", configuration = OAuth2FeignRequestInterceptor.class)
public interface UserConsumer {

    String PREFIX = "/user";

    /**
     * 根据用户名称和邮箱
     *
     * @param user
     * @return
     */
    @PostMapping(value = PREFIX + "/selectByNameOrEmail")
    DmpResult<DmpAuthUser> selectByNameOrEmail(@RequestParam String user);

    /**
     * id查询用户信息
     *
     * @param userCode
     * @return
     */
    @PostMapping(value = PREFIX + "/selectByUserCode")
    DmpResult<DmpAuthUser> selectByUserCode(@RequestParam String userCode);

    /**
     * 修改密码
     *
     * @param user
     * @return
     */
    @PostMapping(value = PREFIX + "/updataPassWord")
    DmpResult<Boolean> updataUser(@RequestBody DmpAuthUser user);

    /**
     * 查询用户名
     *
     * @param username
     * @return
     */
    @PostMapping(value = PREFIX + "/findByName")
    DmpResult<SystemUser> findByName(@RequestParam String username);

    /**
     * 查询openId
     *
     * @return
     */
    @PostMapping(value = PREFIX + "/findByOpenId")
    DmpResult<SystemUser> findByOpenId(@RequestParam String openId);

    /**
     * 根据手机号获取用户
     *
     * @param mobile
     * @return
     */
    @PostMapping(value = PREFIX + "/findByMobile")
    DmpResult<SystemUser> findByMobile(@RequestParam String mobile);

    @PostMapping(value = PREFIX + "/registUser")
    DmpResult<SystemUser> registUser(@RequestBody RegisterUserDto registerUserDto);

    @GetMapping(PREFIX + "/getAllResourceRole")
    DmpResult<List<DmpAuthResourceRole>> getAllResourceRole();
}
